Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
How do make columns in a grid "space-evenly" like with flexbox?

I have this grid CSS

.grid {
    display: grid;
    grid-column-gap: 50px;
    grid-template-columns: repeat(3, 1fr);
}

which is sitting in a div with width: 500px

but I noticed that the first item in the grid "hugs" the left edge of the div but the far most right item doesn't touch the edge of the div.

In flexbox I could achieve this with (near enough):

.flex {
    display: flex;
    justify-content: space-between;
 }

how do I do this responsively with the grid?

I know I can change the grid-column-gap but that seems flakey

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Use auto instead of 1fr and the same justify-content will work like with flexbox:

.grid {
  display: grid;
  grid-column-gap: 50px;
  grid-template-columns: repeat(3, auto);
  justify-content:space-between;
}
<div class="grid">
  <div>aaa</div>
  <div>bbb</div>
  <div>ccc</div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

Consider using auto-fit keyword to fit columns into the available row space by expanding them.

.grid-container {
  display: grid;
  grid-column-gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.grid-item {
  background-color: blue;
  padding: 30px;
}
<div class="grid-container">
  <div class="grid-item"></div>
  <div class="grid-item"></div>
  <div class="grid-item"></div>
  <div class="grid-item"></div>
  <div class="grid-item"></div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda